{include file="public/header" /}
<body>
<section class="main-content-wrapper">
	<section id="main-content">
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-heading">
						<h3 class="panel-title">静态页面生成</h3>
					</div>
					<div class="panel-body">
						<form action="/admin/system/web_info" method="post" enctype="multipart/form-data" class="form-horizontal form-border">
							<div class="form-group">
								<label class="col-sm-2 control-label"></label>
								<div class="col-sm-8">
									<button type="button" class="btn btn-primary btn-lg btn-block btn-primary" data-type="1">生成(更新)网站首页</button>
									<div class="type_1">

									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label"></label>
								<div class="col-sm-8">
									<button type="button" class="btn btn-primary btn-lg btn-block btn-success" data-type="2">生成(更新)网站栏目和文章页面</button>
									<div class="type_2">

									</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</section>
</section>
<script>
	$(document).on('click','button',function(){
		var type = $(this).attr('data-type');
		rewrite(type);
	});
	function rewrite(type){
		$.ajax({
			type: "GET",  //提交方式
			url: "/admin/seo/rewrite",//路径
			data: {type:type},
			dataType: "json",
			success: function (data) {
				if(data.status==0){
					if(type==1){
						$('.type_1').html('<p  class="text-center text-success">生成首页成功!</p>');
					}else if(type==2){
						$('.type_2').html('<p  class="text-center text-success">生成栏目成功,正在生成文章...</p>');
//						$.ajax({
//							type: "GET",  //提交方式
//							url: "/admin/seo/rewrite",//路径
//							data: {type:3},
//							dataType: "json",
//							success: function (data) {
//								if(data.status==0){
//									$('.type_2').html('<p  class="text-center text-success">栏目和文章均生成成功,ok!</p>');
//								}else if(type==2){
//									var html = [];
//									var data_info = data.data;
//									html +='<p class="text-center text-danger">生成文章失败!</p>';
//									html += '<p class="text-center text-warning">失败地址:'+data_info+'</p>';
//									$('.type_2').html(html);
//								}
//
//							}
//						});
					}
				}else{
					if(type==1){
						var html = [];
						var data_info = data.data;
						html +='<p class="text-center text-danger">生成首页失败!</p>';
						html += '<p class="text-center text-warning">失败地址:'+data_info+'</p>';
						$('.type_1').html(html);
					}
					else if(type==2){
						var html = [];
						var data_info = data.data;
						html +='<p class="text-center text-danger">生成栏目失败!</p>';
						html += '<p class="text-center text-warning">失败地址:'+data_info+'</p>';
//						for (var i=0;i<data_info.length;i++)
//						{
//							html += '<p class="text-center text-warning">失败地址:'+data[i]+'</p>';
//						}
						$('.type_2').html(html);
					}
				}
			}
		});
	}

</script>
</body>
</html>
